Skip to content

fix(templates): allow SSR web workers to fetch separate Cloudflare server worker - #1291

Merged
AmanVarshney01 merged 2 commits into
mainfrom
fix/cloudflare-worker-fetch
Oct 22, 2026
Merged

AmanVarshney01 merged 2 commits into
mainfrom
fix/cloudflare-worker-fetch

Conversation

@AmanVarshney01

@AmanVarshney01 AmanVarshney01 commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner

Summary

When the web app and the server are deployed as separate Cloudflare Workers on the same account, a fetch() from the web worker to the server worker's workers.dev URL fails unless the caller has the global_fetch_strictly_public compatibility flag or uses a service binding. The generated alchemy.run.ts only set that flag for Next.js.

This PR adds global_fetch_strictly_public to the generated Cloudflare web workers that call the separate server worker during server rendering:

Frontend Server-side request to the server worker Change
TanStack Start authMiddleware calls authClient.getSession with VITE_SERVER_URL, and SSR queries go through the oRPC/tRPC link flag added
Nuxt the auth-client plugin and useAuthSession (useFetch) run during SSR against serverUrl flag added
SolidStart the home page oRPC query uses deferStream: true and runs during SSR (forwarding request headers) flag added
Next.js server components call authClient.getSession already had the flag
React Router the split-deploy dashboard uses clientLoader, and queries run in the browser unchanged
SvelteKit the split-deploy dashboard sets ssr = false, and queries run in the browser unchanged
Astro, TanStack Router requests run in the browser unchanged

Fixes #1028

Why the flag and not a service binding

The flag is set on these frameworks for every topology, as it already is for Next.js. When the frontend has no separate server, these templates don't make server-side requests to their own URL.

Not verified on a real Cloudflare deployment. I couldn't deploy, so the runtime behavior relies on Cloudflare's documentation.

Verification

  • Generated hono + workers + D1/SQLite/Drizzle + oRPC + better-auth stacks, with webDeploy/serverDeploy set to cloudflare, for tanstack-start, nuxt and solid. bun install, bun run check-types (including packages/infra) and bun run build all pass. The generated alchemy.run.ts has flags: ["nodejs_compat", "global_fetch_strictly_public"] on the web worker. A react-router control still has ["nodejs_compat"].
  • BTS_BUILD_SAMPLES=1 BTS_BUILD_SAMPLE_FILTER=cloudflare bun test test/generated-builds.test.ts: 5 pass
  • BTS_BUILD_SAMPLES=1 BTS_BUILD_SAMPLE_FILTER=workers bun test test/generated-builds.test.ts: 3 pass
  • bun run test:ci: 112 pass, 0 fail
  • bun run check: clean

Summary by CodeRabbit

  • New Features
    • Generated Nuxt websites for Cloudflare now include Node.js compatibility and strictly public fetch compatibility settings.
    • Generated Vite websites retain Node.js compatibility for React Router. Other frameworks handled by this generator now also receive strictly public fetch compatibility settings.

@vercel

vercel Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
create-better-t-stack-web Ready Ready Preview Oct 22, 2026 1:01pm UTC

Request Review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-22T08:05:07.858276Z 3ba184a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8d190ae1-5698-45c5-a627-91edc4943887
📥 Commits

Reviewing files that changed from the base of the PR and between 3ba184a and 94f1892.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 750a00f9-e47d-43ce-bd32-4e0bcdfc3d7e
📥 Commits

Reviewing files that changed from the base of the PR and between 09edd06 and 3ba184a.

📒 Files selected for processing: 1
  • packages/template-generator/src/generators/alchemy/web.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

Walkthrough

Nuxt website generation adds the nodejs_compat and global_fetch_strictly_public flags. Vite website generation adds both flags for frameworks other than React Router, which retains only nodejs_compat.

Changes

Cloudflare compatibility flags

Layer / File(s) Summary
Website compatibility flag generation
packages/template-generator/src/generators/alchemy/web.ts
Nuxt generation adds nodejs_compat and global_fetch_strictly_public. Vite generation adds global_fetch_strictly_public for frameworks other than React Router. React Router retains only nodejs_compat.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 3ba18

No actionable merge-blocking risk was identified.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Linked Issues check Warning Issue #1028 requires global_fetch_strictly_public or a service binding for the separated frontend worker and specifically requests the flag in the generated frontend resource. The current generator … Add global_fetch_strictly_public to the generated Cloudflare Astro frontend resource, or provide an equivalent service binding. Add or update generator coverage that verifies the selected frontend resource contains the required configurat…
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly describes the main change: enabling SSR web workers to fetch a separately deployed Cloudflare server worker.
Out of Scope Changes check Passed The changes are limited to generated Cloudflare web-worker compatibility flags. They support the separated-worker communication objective in issue #1028 for the affected SSR frameworks. No unrelated s…
Full details: Out of Scope Changes check

Explanation

The changes are limited to generated Cloudflare web-worker compatibility flags. They support the separated-worker communication objective in issue #1028 for the affected SSR frameworks. No unrelated source, runtime, or deployment changes are shown.

Full details: Linked Issues check

Explanation

Issue #1028 requires global_fetch_strictly_public or a service binding for the separated frontend worker and specifically requests the flag in the generated frontend resource. The current generator adds the flag for Nuxt, TanStack Start, and SolidStart, and keeps it for Next.js. The astro Cloudflare website still has no compatibility block, and no service binding replaces the flag. The issue's Astro frontend example is therefore not covered by the generated configuration.

Resolution

Add global_fetch_strictly_public to the generated Cloudflare Astro frontend resource, or provide an equivalent service binding. Add or update generator coverage that verifies the selected frontend resource contains the required configuration.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@AmanVarshney01
AmanVarshney01 enabled auto-merge (squash) October 22, 2026 13:00
@AmanVarshney01
AmanVarshney01 merged commit 0e93319 into main Oct 22, 2026
11 checks passed
@AmanVarshney01
AmanVarshney01 deleted the fix/cloudflare-worker-fetch branch October 22, 2026 13:04

This branch was successfully deployed

1 active deployment
Preview — 94f18920 Deployed Oct 22, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable global-fetch-strictly-public or use service binding for separated cloudflare workers

1 participant